<script setup lang="ts">
import { getCredActor } from "@/api/zhang";
import { useRoute, useRouter } from "vue-router";
import { ref, computed } from "vue";

const route = useRoute();
const router = useRouter();

const actor = ref("");
getCredActor(route.query.movieId, route.query.castId).then((res) => {
  actor.value = res.data;
  console.log(actor.value);
});


// 定义显示/隐藏小框的状态
const showPopup = ref(false);

// 切换小框显示状态
const togglePopup = () => {
  showPopup.value = !showPopup.value;
};

// 定义返回首页的函数
const fanhui = () => {
  router.push({
    path: "/",
  });
};


</script>

<template>
  <div class="actor" v-if="actor">
    <div class="a">
      <van-nav-bar :title="actor?.$title" left-arrow @click-left="router.back()" />
      <van-icon name="wap-nav" @click="togglePopup" />
    </div>
    <div @click="fanhui" v-if="showPopup" class="popup">
      <p>首页</p>
    </div>

    <div class="b" v-for="item in actor?.cast" :key="item?.id">
      <div class="c">
        <van-image width="58rem" height="78rem" fit="contain" :src="item?.avatar" />
        <div class="d">
          <h3>{{ item?.cnm }}</h3>
          <p>{{ item?.enm }}</p>
          <span>{{ item?.desc }}</span>
        </div>
      </div>
      <div class="hx"></div>
    </div>
    <footer>
      <div class="e">
        <p><span>猫眼用户服务协议</span> I 客服电话：<span>1234-4321</span></p>
        <p>京ICP备123456号-1 京ICP备123456789123号-1</p>
        <p>广东猫眼文化传媒有限公司</p>
      </div>
      <img
        src="https://obj.pipi.cn/festatic/asgard/resources/images/movie/bottom-logo.png"
        alt=""
      />
    </footer>
  </div>
</template>

<style lang="less" scoped>
/* 定义小框样式 */
.popup {
  position: absolute;
  top: 40rem;
  right: 35rem;
  width: 100rem;
  height: 40rem;
  line-height: 40rem;
  background-color: #ffffff;
  color: #000;
  text-align: center;
  line-height: 20rem;
  border: 1rem solid #ddd;
  border-radius: 4rem;
  box-shadow: 0 2rem 4rem rgba(0, 0, 0, 0.1);
  font-size: 12rem;
  z-index: 1000;
  p{
    line-height: 40rem;
  }
}
footer {
  margin-top: 20rem;
  width: 100%;
  height: 100rem;
  background-color: #f4f4f4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  .e {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  p {
    line-height: 20rem;
    font-size: 11rem;
    color: #a9b2b3;
    span {
      color: #4e759e;
    }
  }
  img {
    width: 78rem;
    height: 22rem;
  }
}
.b {
  width: 100%;
  background-color: white;
  padding-top: 15rem;
  .hx {
    width: 95%;
    height: 16rem;
    background-color: #ffffff;
    margin: 0 auto;
    border-bottom: 1rem solid #f0e3e3;
  }
  .c {
    width: 95%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    .d {
      height: 80rem;
      margin-left: 15rem;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      h3 {
        font-size: 16rem;
        font-weight: 400;
      }
      p {
        font-size: 14rem;
      }
      span {
        font-size: 14rem;
      }
    }
  }
}
.actor {
  background-color: #f4f4f4;
  height: 100vh;
}
:deep(.van-icon-wap-nav) {
  position: absolute;
  font-size: 25rem !important;
  right: 8rem;
  top: 9.5rem;
  z-index: 9999;
}
:deep(.van-badge__wrapper) {
  color: #fff;
  font-size: 20rem;
}
:deep(.van-nav-bar__title) {
  color: #fff;
}
:deep(.van-nav-bar__content) {
  background-color: #e54847;
}
h3,
p {
  margin: 0;
}
</style>
